<template>
  <div class="header">
    <img class="header__icon" src="@image/computer.svg" alt="" />
    <div class="header__device">
      <div class="header__device__item">
        <span class="item__title">设备名称：</span>{{ deviceInfo.deviceName }}
      </div>
      <div class="header__device__item">
        <span class="item__title">设备ID：</span>{{ deviceInfo.uuid }}
      </div>
      <div class="header__device__item">
        <span class="item__title">处理器：</span>{{ deviceInfo.cpuInfo }}
      </div>
    </div>
    <div class="header__os">
      <div class="header__os__item">
        <span class="item__title">系统版本：</span>{{ deviceInfo.platform + deviceInfo.version }}
      </div>
      <div class="header__os__item">
        <span class="item__title">系统类型：</span>{{ deviceInfo.arch }}位操作系统
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { reactive } from 'vue'
import { useDeviceInfoStore } from '@renderer/store/deviceInfo'
const ipcRenderer = window.electron.ipcRenderer

const deviceInfo = reactive({
  deviceName: '',
  cpuInfo: '',
  uuid: '',
  version: '',
  platform: '',
  arch: ''
})

const deviceInfoStore = useDeviceInfoStore()

ipcRenderer.on('get-deviceInfo', (_event, data) => {
  Object.assign(deviceInfo, data)
  deviceInfoStore.updateData(deviceInfo)
})
</script>
<style lang="less" scoped>
.header {
  display: flex;
  align-items: center;
  height: 100px;
  border-bottom: 1px solid #6d6d6d;
  color: #ffffff;
  font-size: 10px;
  &__icon {
    width: 60px;
    height: auto;
    margin-left: 25px;
    margin-right: 20px;
  }
  &__device, &__os {
    height: 50px;
    margin-right: 40px;
  }
}
.item__title {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}
</style>
